
import { Injectable } from '@angular/core';
import { Router, Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';


import { ForumService } from './ForumService';
import { NewsCategory } from '../models/NewsCategory';

@Injectable()
export class NewsResolveService implements Resolve<NewsCategory[]> {

  constructor(private forumService: ForumService) {}

  resolve(route: ActivatedRouteSnapshot): Observable<NewsCategory[]>  {

    return this.forumService.getForumTypes().pipe(map((res) => {
      return res.res;
    }));
  }
}

